package pub.wii.cook.thrift.client;

import lombok.SneakyThrows;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import pub.wii.cook.thrift.Ticket;
import pub.wii.cook.thrift.TicketRequest;
import pub.wii.cook.thrift.TicketResponse;
import pub.wii.cook.thrift.TicketService;

import java.util.List;

public class TicketClient {
    @SneakyThrows
    public static void main(String[] args) {
        TTransport transport = new TSocket("localhost", 9090);
        transport.open();
        TProtocol protocol = new TBinaryProtocol(transport);
        TicketService.Client client = new TicketService.Client(protocol);

        // 发送请求
        TicketRequest request = new TicketRequest();
        request.setId(1);
        TicketResponse response = client.getTicket(request);
        System.out.println(response);

        // 发送请求
        List<Ticket> tickets = client.listTicket();
        System.out.println(tickets);
    }
}
